add compatibility with aws iam auth custom jdbc driver - #29
Open
mononen wants to merge 1 commit into
Open
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support custom drivers and AWS RDS IAM authentication
The problem
OmniSQL dispatches to a native driver by substring-matching the workspace's driver id —
postgres-jdbccontains "postgres",mysql8contains "mysql". That holds for stock drivers, butbreaks for two increasingly common setups.
1. Custom drivers have opaque ids. A user-defined driver in a DBeaver-compatible client gets a
generated id — often a UUID, e.g.
35379A2C-3AE9-529E-B72B-244C753C055B. It names no engine, so norouting branch matches, and the connection falls through to the CLI fallback and fails. This affects
any hand-rolled or generated driver, including anything built on the
AWS Advanced JDBC Wrapper, whose URLs also carry
a wrapper sub-protocol (
jdbc:aws-wrapper:postgresql://…) that a naive URL parse misreads.The connection record still identifies the engine, just not in the driver id:
providersayspostgresql/mysql, and the JDBC URL names the engine behind any wrapper.2. IAM-authenticated connections have no password to read. With RDS IAM auth the credential is a
signed token, minted per connection and valid 15 minutes. Nothing is stored in the workspace, so
OmniSQL had nothing to authenticate with, and such connections frequently omit the database username
too. TLS is mandatory — RDS rejects IAM tokens sent in cleartext.
What changed
Driver dialect resolution (
src/utils.ts,src/config-parser.ts). When a driver id names noknown engine, fall back to the connection's
provider, then to the JDBC URL's sub-protocol, scanningpast wrapper protocols. Resolution happens once at parse time, so all existing routing — direct
queries, pools, transactions, query analysis, schema diff — keeps working unchanged. The raw id is
kept as
driverIdfor display and error messages. Host, port and database are also backfilled fromthe JDBC URL when the config omits them.
AWS RDS IAM authentication (
src/auth/iam-auth.ts, new). Detected from AWS Advanced JDBC Wrapperproperties (
wrapperPlugins: "iam") or aniam-flavoured auth model. Tokens are minted withaws rds generate-db-auth-token, delegating to the AWS CLI so SSO and role-chained profiles work asthe user already configured them — no new AWS SDK dependency. Tokens are cached 13 minutes under
their 15-minute lifetime, keyed per host/port/user/region/profile.
Long-lived pools refresh rather than expiring:
pgreceives an asyncpasswordfunction andmysql2an asyncmysql_clear_passwordplugin, each invoked per physical connection.Where a connection records no username, it is derived from the caller's AWS identity — either the
assumed SSO session name, or, for role-chained profiles whose session name is SDK-generated
(
botocore-session-1785446405), by stripping the profile prefix off the role name. Expired SSOsessions produce an error naming the profile to re-authenticate.
Shared TLS resolution (
src/auth/ssl.ts, new). The direct-query and pooled paths each had theirown copy, reading different property locations and disagreeing about what
requiremeant. They nowshare one implementation, which also fixes two bugs:
propertiesblock the JSON workspace format writes. PostgreSQL already handled both.REQUIREDimplied full certificate verification. Per MySQL's documentedssl-modesemantics,
REQUIREDencrypts without validating the chain; onlyVERIFY_CAandVERIFY_IDENTITYverify it. The old behaviour cannot work against managed engines like RDS, whoseCA is absent from the system trust store.
Compatibility
Stock drivers are unaffected: an id that already names its engine is returned untouched, and the
IAM path only activates on connections that declare it.
Two observable changes worth review:
connection.drivernow holds the resolved dialect.list_connectionsadditionally reportsdriverIdandprovider, but only when resolution was needed.REQUIREDfix above is a deliberate behaviour change. Connections that set a MySQL TLSmode and relied on the previous stricter-than-documented verification would now encrypt without
verifying. Setting
VERIFY_CA/VERIFY_IDENTITYrestores it.No new runtime dependencies. Two new optional environment variables,
OMNISQL_AWS_CLI_PATHandOMNISQL_IAM_TOKEN_TIMEOUT, both documented in the README.Testing
52 new unit tests (94 total, all passing) covering dialect resolution, JDBC URL parsing, IAM
detection, region and username derivation, token caching, and TLS mode semantics. AWS calls run
through an injectable command runner, so the suite needs no AWS access.
Verified end to end through the MCP tool layer against live Amazon RDS: PostgreSQL 17.7 and MySQL
8.4.8, both via a custom AWS Advanced JDBC Wrapper driver with IAM auth and no stored credentials,
through both the direct-query and pooled-transaction paths.
Checked for regressions against a workspace of 20 connections, 18 of them stock password-based
Postgres and MySQL. Results were identical before and after the change.